package gui;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Frame extends JFrame {
	private ConnectionPanel connectionPanel;
	private CameraPanel cameraPanel;
	private JMenuBar menuBar;
	private JMenu menu;
	private JMenuItem menuItem;

	public Frame() {
		try {			
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			System.out.println("Look and Feel unsupported");
		}
		
		setTitle("Camera Surveillance PRO");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.NORTH);
		panel.setLayout(new BorderLayout(0, 0));

		cameraPanel = new CameraPanel();
		panel.add(cameraPanel, BorderLayout.CENTER);
		cameraPanel.setBounds(0, 0, 771, 287);
		cameraPanel.setVisible(false);
		connectionPanel = new ConnectionPanel();
		panel.add(connectionPanel, BorderLayout.EAST);
		connectionPanel.setBounds(12, 298, 447, 326);	
		
		
		menuBar = new JMenuBar();
		menu = new JMenu("Settings");		
		
		menuItem = new JMenuItem("Connections");
		menu.add(menuItem);
		
		menuItem.addActionListener(new ActionListener(){	
			public void actionPerformed(ActionEvent arg0) {	
				connectionPanel.setVisible(!connectionPanel.isVisible());				
				pack();
			}		
		});
		
		menuBar.add(menu);
		setJMenuBar(menuBar);

		setVisible(true);
		pack();

	}

	public ConnectionPanel getConnectionPanel() {
		return connectionPanel;
	}

	public CameraPanel getCameraPanel() {
		return cameraPanel;
	}
}
